package com.y.simple.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;

import com.y.simple.dto.UserMainDto;
import lombok.Data;

/**
 * <p>
 * 
 * </p>
 *
 * @author y2014188432
 * @since 2023-05-23
 */
@Data
@TableName("user_main")
@Schema(name = "UserMain对象", description = "")
public class UserMain implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(name = "id",description = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(name = "userName",description = "用户名")
    private String userName;

    @Schema(name = "userPhone",description = "用户手机号")
    private String userPhone;

    @Schema(name = "userEmail",description = "用户邮箱")
    private String userEmail;

    @Schema(name = "userPassword",description = "用户密码")
    private String userPassword;

    @Schema(name = "userType",description = "身份")
    private String userType;

    @Schema(name = "userState",description = "用户状态")
    private String userState;

    /**
     * <h1>用户权限</h1>
     * 格式：[权限id];[权限id]<br>
     * 例子： 1;2;3;5
     */
    @Schema(name = "userPower",description = "用户权限")
    private String userPower;

    @Schema(name = "createTime",description = "创建时间")
    private LocalDateTime createTime;

    @Schema(name = "isDelete",description = "删除标记 0 未删除 1 删除")
    private String isDelete;


    /**
    * 将 dto 中的信息更新到 entity 中
    * @param dto dto
    * @return 更新后的 entity
    */
    public UserMain updateByDto(UserMainDto dto) {
        setId(dto.getId());
        setUserName(dto.getUserName());
        setUserPhone(dto.getUserPhone());
        setUserEmail(dto.getUserEmail());
        setUserPassword(dto.getUserPassword());
        setUserType(dto.getUserType());
        setUserState(dto.getUserState());
        setUserPower(dto.getUserPower());
        setIsDelete(dto.getIsDelete());
        return this;
    }

}
